home *** CD-ROM | disk | FTP | other *** search
/ Over 1,000 Windows 95 Programs / Over 1000 Windows 95 Programs (Microforum) (Disc 2).iso / 1133 / neural.h < prev    next >
C/C++ Source or Header  |  1997-04-16  |  3KB  |  114 lines

  1. #ifndef __CNEURAL_H__
  2. #define __CNEURAL_H__
  3.  
  4. #define NN_DYNAMIC        1
  5. #define NN_DATAMAT        2
  6. #define NN_PARAMSLOADED    4
  7.  
  8. #define NN_STHRU    // Straight through connections
  9.  
  10.     struct _neural {
  11.         long m_version;   // version
  12.         int m_istate;
  13.         int m_ninputs;
  14.         int m_nhidden;
  15.         int m_noutputs;
  16.  
  17.         float *m_ni;  /* declare input neurons */
  18.         float *m_nout;    // output of output layer
  19.         float *m_ocircw;
  20.         float *m_olastoutputv;   // output of output
  21.  
  22. // declare hidden layer neurons
  23.         float **m_hinputw;   // weight of input to hidden
  24.         float *m_houtputv;   // output of hidden
  25.         float *m_hlastoutputv;   // output of hidden
  26.         float *m_htheta;
  27.         float *m_hcircw;
  28. // declare output neurons
  29.         float **m_oinputw;   // weight of hidden to output
  30.         float *m_otheta;
  31.  
  32. #ifdef NN_STHRU
  33.         float **m_iinputw;   // weight of input to output
  34. #endif
  35.  
  36. // Now for the dynamic variables
  37.  
  38.         PARAMS *m_params;
  39.         DATAMAT *m_dm;
  40.  
  41. // declare hidden layer neurons
  42.         float **m_hlastdelta; // last delta weight of input/hidden
  43.         float *m_hlastvar;    // last VAR
  44.         float *m_hlearn;
  45.         float *m_htlearn;
  46. // declare output neurons
  47.         float **m_olastdelta; // last delta weight of hidden/output
  48. #ifdef NN_STHRU
  49.         float **m_ilastdelta; // last delta weight of input/output
  50. #endif
  51.         float *m_olastvar;    // last var weight of output
  52.         float *m_otraining;
  53.         float *m_olearn;
  54.         float *m_otlearn;
  55.  
  56.         float *m_startp;
  57.         int m_NDIM;
  58.         float *m_pcom;
  59.         float *m_xicom;
  60.         float *m_xt;
  61.         float *m_g,*m_h,*m_xi;
  62.         float m_sumerr2;
  63.         long m_cnt;
  64.         float m_stats[7];
  65.         int m_itmax; // # of iterations in CG optim
  66.     };
  67.     typedef struct _neural NEURAL;
  68.  
  69.     NEURAL *NCreateNeural();
  70.     void NDeleteNeural(NEURAL *pN );
  71.     int NImportNetwork (NEURAL *pN, FILE *fd);
  72.     NEURAL *LoadNetwork (char *filename);
  73.     void DumpNeural(NEURAL *pN, FILE *fd);
  74.  
  75.     void NAddHidden(NEURAL *pN);
  76.     void NFeedForward(NEURAL *pN);
  77.     int NBackProp1(NEURAL *pN,int cnt);
  78.     void NClearDelta(NEURAL *pN);
  79.     void NInitializeNetwork(NEURAL *pN);
  80.     void NNewTrainingSet(NEURAL *pN, int t,int flag);
  81.     int NAI(NEURAL *pN, int flag,int a);
  82.     float NCalcRsquare(NEURAL *pN);
  83.     float NCheckTol(NEURAL *pN,float *min, float *max, int *nmin, int *nmax);
  84.     int NQuickTrain(NEURAL *pN,int mode,int increment);
  85.  
  86. // Conj Grad routines
  87.     void Nfrprmn(NEURAL *pN,float *p, float ftol, int *iter, float *fret);
  88.     float Nbrent(NEURAL *pN,float ax, float bx, float cx, float tol,float *xmin);
  89.     void Nmnbrak(NEURAL *pN,float *ax, float *bx, float *cx, float *fa, float *fb,float *fc);
  90.     float Nf1dim(NEURAL *pN,float x);
  91.     void Nlinmin(NEURAL *pN,float *p, float *xi, float *fret);
  92.     void NforwardDIffGradient (NEURAL *pN,float *x0, float *g);
  93.     float NErrorFunction(NEURAL *pN,float* x);
  94.     void Nrerror(char *error_text);
  95.     void NCGTrain(NEURAL *pN);
  96.     void NSetDM( NEURAL *pN, DATAMAT *a);
  97.     void NInterrogate(NEURAL *pN,float *Ivec,float *Ovec);
  98.  
  99. /*
  100.     void SetInput(const int neuron, float f);
  101.     void SetRInput(const int neuron, float f);
  102.     float GetInput(const int neuron);
  103.     float GetOutput(const int neuron);
  104.     float GetTrain(const int neuron);
  105.     float GetRInput(const int neuron);
  106.     float GetROutput(const int neuron);
  107.     float GetRTrain(const int neuron);
  108.  
  109. */
  110.  
  111. #endif // __CNEURAL_H__
  112.  
  113.  
  114.